﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using SilverlightGolf.Core;

namespace SilverlightGolf.Physics
{
    public class SimulationEngine : ISimulationEngine
    {
        private ListWithEvents<Geom> _geoms = new ListWithEvents<Geom>();
        public IList<Geom> Geoms
        {
            get { return _geoms; }
        }

        public bool AllStopped { get; private set; }

        public SimulationEngine()
        {
        }

        public void Update(double dt)
        {
            foreach (var geom in _geoms)
            {
                geom.Body.Update(dt);
            }

            bool tempAllStopped = true;
            foreach (var geom in _geoms)
            {
                if (geom.Body.Velocity.Length != 0)
                {
                    tempAllStopped = false;
                    break;
                }
            }

            AllStopped = tempAllStopped;
        }
    }
}
